<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new RecursiveRegexIterator.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.recursiveregexiterator.html">RecursiveRegexIterator</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="recursiveregexiterator.getchildren.html">RecursiveRegexIterator::getChildren</a></div>
 <div class="up"><a href="class.recursiveregexiterator.html">RecursiveRegexIterator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="recursiveregexiterator.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RecursiveRegexIterator::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0)</p><p class="refpurpose"><span class="refname">RecursiveRegexIterator::__construct</span> &mdash; <span class="dc-title">Creates a new RecursiveRegexIterator.</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-recursiveregexiterator.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>RecursiveRegexIterator::__construct()</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.recursiveiterator.html" class="type RecursiveIterator">RecursiveIterator</a></span> <code class="parameter">$iterator</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$regex</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = self::MATCH</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$preg_flags</code><span class="initializer"> = 0</span></span>
  ]]] )</div>


  <p class="para rdfs-comment">
   Creates a new regular expression iterator.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-recursiveregexiterator.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">iterator</code></em></dt>

     <dd>

      <p class="para">
       The recursive iterator to apply this regex filter to.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">regex</code></em></dt>

     <dd>

      <p class="para">
       The regular expression to match.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">mode</code></em></dt>

     <dd>

      <p class="para">
       Operation mode, see <span class="methodname"><a href="regexiterator.setmode.html" class="methodname">RegexIterator::setMode()</a></span> for a list
       of modes.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">flags</code></em></dt>

     <dd>

      <p class="para">
       Special flags, see <span class="methodname"><a href="regexiterator.setflags.html" class="methodname">RegexIterator::setFlags()</a></span> for a list
       of available flags.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">preg_flags</code></em></dt>

     <dd>

      <p class="para">
       The regular expression flags. These flags depend on the operation mode parameter:
      </p>
      <p class="para">
      <table class="doctable table">
        <caption><strong><a href="class.regexiterator.html" class="classname">RegexIterator</a> preg_flags</strong></caption>
        
         <thead>
          <tr>
           <th>operation mode</th>
           <th>available flags</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><var class="varname"><var class="varname">RecursiveRegexIterator::ALL_MATCHES</var></var></td>
           <td>
            See <span class="function"><a href="function.preg-match-all.html" class="function">preg_match_all()</a></span>.
           </td>
          </tr>

          <tr>
           <td><var class="varname"><var class="varname">RecursiveRegexIterator::GET_MATCH</var></var></td>
           <td>
            See <span class="function"><a href="function.preg-match.html" class="function">preg_match()</a></span>.
           </td>
          </tr>

          <tr>
           <td><var class="varname"><var class="varname">RecursiveRegexIterator::MATCH</var></var></td>
           <td>
            See <span class="function"><a href="function.preg-match.html" class="function">preg_match()</a></span>.
           </td>
          </tr>

          <tr>
           <td><var class="varname"><var class="varname">RecursiveRegexIterator::REPLACE</var></var></td>
           <td>
            none.
           </td>
          </tr>

          <tr>
           <td><var class="varname"><var class="varname">RecursiveRegexIterator::SPLIT</var></var></td>
           <td>
            See <span class="function"><a href="function.preg-split.html" class="function">preg_split()</a></span>.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-recursiveregexiterator.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3805">
    <p><strong>Example #1 <span class="function"><strong>RecursiveRegexIterator::__construct()</strong></span> example</strong></p>
    <div class="example-contents"><p>
      Creates a new RegexIterator that filters all strings that start with &#039;test&#039;.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$rArrayIterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">RecursiveArrayIterator</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'test1'</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'tet3'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'test4'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'test5'</span><span style="color: #007700">)));<br /></span><span style="color: #0000BB">$rRegexIterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">RecursiveRegexIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$rArrayIterator</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'/^test/'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RecursiveRegexIterator</span><span style="color: #007700">::</span><span style="color: #0000BB">ALL_MATCHES</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$rRegexIterator&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key1&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$value1</span><span style="color: #007700">)&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$rRegexIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hasChildren</span><span style="color: #007700">())&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;print&nbsp;all&nbsp;children<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Children:&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$rRegexIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getChildren</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$value&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"No&nbsp;children\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
No children
Children: test4 test5
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-recursiveregexiterator.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.preg-match.html" class="function" rel="rdfs-seeAlso">preg_match()</a> - 执行一个正则表达式匹配</span></li>
    <li class="member"><span class="function"><a href="function.preg-match-all.html" class="function" rel="rdfs-seeAlso">preg_match_all()</a> - 执行一个全局正则表达式匹配</span></li>
    <li class="member"><span class="function"><a href="function.preg-replace.html" class="function" rel="rdfs-seeAlso">preg_replace()</a> - 执行一个正则表达式的搜索和替换</span></li>
    <li class="member"><span class="function"><a href="function.preg-split.html" class="function" rel="rdfs-seeAlso">preg_split()</a> - 通过一个正则表达式分隔字符串</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.recursiveregexiterator.html">RecursiveRegexIterator</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="recursiveregexiterator.getchildren.html">RecursiveRegexIterator::getChildren</a></div>
 <div class="up"><a href="class.recursiveregexiterator.html">RecursiveRegexIterator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
